﻿using RockBus.Configuration.Interfaces;
using RockBus.PerformanceCounters.Interfaces;
using System;
using System.Collections.Generic;
using System.Diagnostics;

namespace RockBus.PerformanceCounters
{
    public class PerformanceCounterConfiguration : IPerformanceCounterConfiguration
    {
        public PerformanceCounterConfiguration(IReadOnlyConfiguration configuration)
        {
            this.ReadOnlyConfiguration = configuration;

            var process = Process.GetCurrentProcess();
            this._instanceName = string.Format("{0}::{1}::{2}", process.ProcessName, process.Id, AppDomain.CurrentDomain.Id);

            this._processStartTime = process.StartTime;
            //this._updateIntervalMs = configuration.PerformanceCounterUpdateIntervalMs;
        }

        public IReadOnlyConfiguration ReadOnlyConfiguration { get; private set; }

        public string CategoryName { get { return RockBusPerformanceCounterMetadata.CategoryName; } }

        public string CategoryHelp { get { return RockBusPerformanceCounterMetadata.CategoryHelp; } }

        private readonly string _instanceName;

        public string InstanceName { get { return this._instanceName; } }

        public IEnumerable<string> OperationNames
        {
            get
            {
                yield return "ReceiveMessage";
                yield return "DeliverMessage";
                yield return "PersistMessage";
                yield return "PublishMessage";
                //yield return "ExecutePipeline";
            }
        }

        private readonly DateTime _processStartTime;

        public DateTime ProcessStartTime { get { return this._processStartTime; } }
    }
}